package org.xlx.xlx_oa.role_user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xlx.xlx_oa.common.ResponseBean;
import org.xlx.xlx_oa.role_user.api.SysRouteApi;
import org.xlx.xlx_oa.role_user.domain.dto.SysRouteDto;
import org.xlx.xlx_oa.role_user.domain.vo.SysRouteVo;
import org.xlx.xlx_oa.role_user.service.SysRouteService;

import java.util.List;

@RestController
@RequestMapping("/v1/sys-route")
public class SysRouteController implements SysRouteApi {
    @Autowired
    private SysRouteService routeService;

    @PostMapping("/save")
    @Override
    public ResponseBean saveEntity(@RequestBody SysRouteVo vo) {
        return ResponseBean.successFactory(routeService.saveEntity(vo));
    }

    @GetMapping("/remove/{id}")
    @Override
    public ResponseBean removeEntity(@PathVariable(value = "id") Long id) {
        return ResponseBean.successFactory(routeService.removeEntity(id));
    }

    @PostMapping("/routes")
    @Override
    public ResponseBean<List<SysRouteDto>> getRoutes() {
        return ResponseBean.successFactory(routeService.getRoutes());
    }
}
